<template>
  <div class="g-app">
    <!-- 左侧导航栏 -->
    <div class="sidebar">
      <div class="logo">
        <h3>Vue3 Admin</h3>
      </div>
      <nav class="nav">
        <!-- 三种写法都可以实现跳转 -->
        <RouterLink to="/route-test/home-first">首页</RouterLink>
        <router-link :to="{name: 'xinwen'}">新闻</router-link>
        <router-link :to="{path: '/route-test/about'}">关于</router-link>
      </nav>
    </div>

    <!-- 右侧内容区 -->
    <div class="main-content">
      <div class="header">
        <h2>Vue3 路由测试</h2>
      </div>
      <div class="container">
       <RouterView></RouterView>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { shallowRef } from 'vue';
</script>

<style scoped>
/* 全局样式 */
.g-app {
  display: flex;
  height: 100vh;
  width: 100vw; /* 确保宽度铺满屏幕 */
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 左侧导航栏样式 */
.sidebar {
  width: 200px;
  background-color: #333;
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100%; /* 确保高度铺满 */
}

.sidebar .logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid #444;
}

.sidebar .logo h3 {
  margin: 0;
  font-size: 1.5rem;
}

.sidebar .nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.sidebar .nav a {
  display: block;
  padding: 10px;
  margin-bottom: 10px;
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.sidebar .nav a:hover {
  background-color: #555;
}

/* 右侧内容区样式 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 20px; /* 添加一些内边距 */
}

.main-content .header {
  padding: 20px 0;
  border-bottom: 1px solid #ddd;
  text-align: center;
}

.main-content .header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.main-content .container {
  flex: 1;
  padding: 20px;
  overflow: auto;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-top: 20px; /* 添加一些间距 */
}
</style>
